/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Chat;

/**
 *
 * @author danielsl & thorerikmidtb.
 */
public class Bot {
    Long startTime = System.currentTimeMillis()/1000;
    String passcode = "123";

    /**
     * Empty constructor, nothing to it.
     */
    public Bot(){
    }
    
    /**
     * This method is used by the ServerImpl class, when users wants help.
     * @return String
     */
    public String help(){
        String helpMessage = " Hello, and welcome to Martleif, the greatest bot in 2011!\n\nI see you have a problem (atleast you wrote /help for a reason...)\n\n"
                + "This chat program is somewhat different from other chat program you may be familiar with.\n\n"
                + "There are several commands which this program supports:"
                + "\n\n/rename newusername <- Which will give you a new username."
                + "\n\n/help <- Which you already typed in, it will give you this message!"
                + "\n\n/opme passcode <- Will give you admin rights for the channel!"
                + "\n\n/opwho <- Will show you who is registered as OP on this server"
                + "\n\n/kick username <- Not liking a person in particular AND got op? Well, this is the command for you :D"
                + "\n\n/uptime <- Will give you the uptime of our beloved server, in seconds!"
                + "\n\n/quizstart <- Starting up the lil´quizz-o-tron! Only for OP."
                + "\n\n/quizjoin <- If there is a quiz starting, this is what you want to do, joining the quiz :D"
                + "\n\n/quizanswer <- If there is a quiz going on, you have joined it, and the questions are pouring in, type /quizanswer answer. Be fast! Or someone else will get the point."
                + "\n\n/quizquit <- Only for OP, will stop the quiz!";
        return helpMessage;
    }
    /**
     * This method is used by the ServerImpl class, when users wants to know the uptime of the server.
     * @return String
     */
    public String uptime(){
        Long currentTime = System.currentTimeMillis()/1000;
        Long calculatedUptime = currentTime - startTime;
        return "I heed thy call, the uptime of the server is: "+ calculatedUptime +" seconds.";
    }
    /**
     * This method is used by the ServerImpl class, when users wants to have OP rights. It only checks if the pass code is correct or not.
     * @param passcode
     * @return true if the is correct, false otherwise
     */
    public boolean getOP(String passcode){
        if(this.passcode.equals(passcode)){
            return true;
        } else return false;
    }

    /**
     * This method will be used by the ServerImpl class, when a user trying to get OP, have the correct pass code.
     * @param adminName
     * @return String
     */
    public String okOP(String adminName){
        String adminConnected = adminName +" is a new OP on this server. Be nice =)";
        return adminConnected;
    }
    /**
     * This method will be used by the ServerImpl class, when a user trying to get OP, does not have the correct pass code.
     * @param passcode
     * @return String
     */
    public String errorOP(String passcode){
        String wrongPasscode = "That is NOT the correct passcode! I am afraid I can not give you operator rights!\nYou typed in: " +passcode + ". Are you sure that is the correct passcode?";
        return wrongPasscode;
    }
    /**
     * This method will be used by the ServerImpl class, when a user trying to do something that he/she must have OP rights for.
     * @return String
     */
    public String notOP(){
        String error = "I am sorry, you are not a registered OP on this server.\nPlease type /opme password to get OP rights.";
        return error;
    }
    /**
     * This method will be used by the ServerImpl class, when users are trying to list out all the OPs on the server, when there are in fact, none connected.
     * @return String
     */
    public String noOPHere(){
        String noOP = "I am afraid there are no OP online at the moment =(";
        return noOP;
    }
    /**
     * This method will be used by the ServerImpl class, when users who are already OP, tries to get OP rights once more.
     * @return String
     */
    public String alreadyOP(){
        String alreadyOP = "I am sorry, but you already have OP rights, what more do you want from me?!";
        return alreadyOP;
    }
    /**
     * This method will be used by the ServerImpl class, when an OP starts the quiz.
     * @param adminName
     * @return String
     */
    public String quizStart(String adminName){
        String quizStart = "The time is nigh! " + adminName + " just booted up the good old QUIZ machine! Please type in /quizjoin to join. The registration will be closed in 1 minute!";
        return quizStart;
    }
    /**
     * This method will be used by the ServerImpl class when the quiz registration process is completed.
     * @return String
     */
    public String quizSoonStarting(){
        String soonStarting = "Good luck again everyone, the first question will pop up in 15 seconds. Please write /quizanswer yes or /quizanswer no after every question. If you fail to do this"
                + " in a timed manner (you have 20 seconds AND the first one to write the correct answer get 1 point!), you loose!";
        return soonStarting;
    }
    /**
     * This method will be used by the ServerImpl class when an OP tries to start the quiz, but when there is already a quiz running.
     * @return String
     */
    public String quizError(){
        String quizError = "I am sorry, but it seems there is already a quiz up and running.";
        return quizError;
    }
    /**
     * This method will be used by the ServerImpl class when users are registering for the quiz.
     * @return String
     */
    public String quizJoined(){
        String quizJoined = "Welcome to the 2011 Championship QuizWiz 1337!";
        return quizJoined;
    }

    /**
     * This method will be used by the ServerImpl class, when there are users trying to join in on a quiz, even if there is no quiz up and running.
     * @return String
     */
    public String quizJoinedError(){
        String quizJoinedError = "Uhm, no OP has started the quiz-ma-tron yet. Feeling well are we? Ask an OP to start the quiz!";
        return quizJoinedError;
    }
    /**
     * This method will be used by the ServerImpl class, when there are users trying to answer the quiz questions, even if they are not registered for the quiz.
     * @return String
     */
    public String quizJoinedError2(){
        String quizJoinedError = "What are you doing? You are not registered for the quiz!";
        return quizJoinedError;
    }
    /**
     * This method will be used by the ServerImpl class, when there are users trying to register for the quiz more than one time.
     * @return String
     */
    public String quizAlreadyJoined(){
        String quizAlreadyJoined = "You are already registered for the quiz. Calm down!";
        return quizAlreadyJoined;
    }
    /**
     * This method will be used by the ServerImpl class, when there is still time to register for the quiz.
     * @return String
     */
    public String quizRegistrationSoonCloses(){
        String quizNearlyClosed = "Hurry up people, quiz registration is open for 30 more seconds, please type in /quizjoin to join!";
        return quizNearlyClosed;
    }
    /**
     * This method will be used by the ServerImpl class, when users are trying to register for the quiz, even if the registration process is completed.
     * @return String
     */
    public String quizRegistrationClosed(){
        String closed = "I am afraid, you missed your chance! The quiz registration is closed. Better luck next time!";
        return closed;
    }
    /**
     * This method will be used by the ServerImpl class, when the quiz registration process is completed, broadcasting it to everyone on the server.
     * @return String
     */
    public String quizRegistrationClosedBroadcast(){
        String broadcastClosed = "The quiz registration is now closed. The quiz will commence shortly, good luck to everyone who joined! =)";
        return broadcastClosed;
    }
    /**
     * This method will be used by the ServerImpl class, when a user is trying to answer the quiz question, and have the correct answer.
     * @param answer
     * @return String
     */
    public String quizYourAnswer(String answer){
        String yourAnswer = "You answered: " + answer +  ". That is correct :D";
        return yourAnswer;
    }
    /**
     * This method will be used by the ServerImpl class, when a user is trying to answer the quiz question, but the correct answer is already given.
     * @return String
     */
    public String quizAlreadyAnswered(){
        String alreadyAnswered = "Too late, someone has already answered correct to this question, better luck next time =)";
        return alreadyAnswered;
    }
    /**
     * This method will be used by the ServerImpl class, when a user is trying to answer the quiz question, but the answer is not correct.
     * @param answer
     * @return String
     */
    public String quizWrongAnswer(String answer){
        String wrongAnswer = "I am afraid that your answer: " +answer +". Is totally wrong! Try again, noone else has still written the correct answer!";
        return wrongAnswer;
    }
    /**
     * This method will be used by the ServerImpl class, when an OP stops the quiz, before it has been completed.
     * @param name
     * @return String
     */
    public String quizStop(String name){
        String stopped = name + " has stopped the quiz! I do not know why :(";
        return stopped;
    }
    /**
     * This method will be used by the ServerImpl class, when the quiz registration process is completed, and there is noone registered.
     * @return String
     */
    public String noQuiz(){
        String noQuiz = "I am afraid NOONE registered for the quiz, NOONE! The quiz-ma-tron is sad, very, very sad =(";
        return noQuiz;
    }
    /**
     * This method will be used by the ServerImpl class, when an OP kicks a user.
     * @param userName
     * @return String
     */
    public String kick(String userName){
        String kick = "I am deeply sorry in doing this, but one of my masters, " +userName + ", wants to kick you! Bu-bye!";
        return kick;
    }

    /**
     * This method will be used by the ServerImpl class, when an OP tries to kick someone who does not exists.
     * @param user
     * @return String
     */
    public String noneToKick(String user){
        String noToKick = "I am sorry, but I cannot find this user: " +user + ". Are you sure that was the correct name?";
        return noToKick;
    }

    /**
     * This method will be used by the ServerImpl class, when an OP kicks a user, publishing it to everyone connected.
     * @param username
     * @param admin
     * @return String
     */
    public String userKicked(String username, String admin){
        String userKicked = "The furious OP: " +admin +", has raised the hammer of kick, and abolished " +username + " to the netherworld!";
        return userKicked;
    }

    /**
     * This method will be used by the ServerImpl class, when someone tries to whisper someone who is not online.
     * @param user
     * @return String
     */
    public String userNotHere(String user){
        String userNotHere = "I am afraid that I am eavesdropping on your private chat, but it seems that your friend " + user + " is not here.";
        return userNotHere;
    }

    /**
     * This method will be used by the ServerImpl class, when someone use the rename method.
     * @param otherUser
     * @return String
     */
    public String nameTaken(String otherUser){
        return "There is already a user named " + otherUser +". You are now known as " + otherUser + "1 but please /rename yourself to something else.";
    }

    /**
     * This method will be used by the ServerImpl class, it includes all the quiz questions.
     * @param nr
     * @return String
     */
    public String quizQuestion(int nr){
        switch(nr) {
            case 1: return "Can a shark sleep and lay still?";
            case 2: return "Is USA bigger than China population wise?";
            case 3: return "Can dogs look up into the sky?";
            case 4: return "Is 2 times 2 divided by 2, 1?";
            case 5: return "Can 16 year olds drive with a 21 year old as their driving instructor?";
            case 6: return "Do monkeys lay eggs?";
            case 7: return "Is 1 dollar worth more than 1 Euro?";
            case 8: return "Is 0 considered an even number?";

        }
        return null;
    }
    /**
     * This method will be used by the ServerImpl class, it includes all the correct answers to the quiz questions.
     * @param nr
     * @return String
     */
    public String quizAnswer(int nr){
        switch(nr) {
            //case 1: return "Dummy case, this case will never be checked!";
            case 2: return "no";
            case 3: return "no";
            case 4: return "no";
            case 5: return "no";
            case 6: return "no";
            case 7: return "no";
            case 8: return "no";
            case 9: return "yes";
        }
        return null;
    }
    /**
     * This method returns the pass code for OP rights.
     * @return String
     */
    public String getPasscode() {
        return passcode;
    }
    /**
     * This method returns the time for when the server started up.
     * @return Long
     */
    public Long getStartTime() {
        return startTime;
    }
    /**
     * This method sets the pass code to get OP rights.
     * @param passcode
     */
    public void setPasscode(String passcode) {
        this.passcode = passcode;
    }
    /**
     * This method sets the start time for when the server started up.
     * @param startTime
     */
    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }
}
